from django.conf import settings

from celery_task.main import celecry_app
from celery_task.sms.yunpian import YunPian
import logging

logger = logging.getLogger('django')


@celecry_app.task()
def send_sms_code(mobile, code):
    """
    发送短信验证码s
    :param mobile: 手机号
    :param code: 验证码
    :return:
    """
    print(settings.YUNPIAN_APIKEY)
    try:
        yun_pian = YunPian(settings.YUNPIAN_APIKEY)
        result = yun_pian.send_semd(code, mobile=mobile)
        return result
    except:
        logger.error("验证码发送错误")
